<?php
// +----------------------------------------------------------------------
// | 投票模型
// +----------------------------------------------------------------------
// | @link
// +----------------------------------------------------------------------
// | @copyright
// +----------------------------------------------------------------------
// | @licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | @author Haijun Wu <nicholasinlove@126.com>
// +----------------------------------------------------------------------
// | $Id: VoteModel.class.php 6 2011-02-04 11:57:05Z nicholasinlove1986@gmail.com $
// +----------------------------------------------------------------------


class VoteModel extends Model {

	public $_validate	=	array(
		array('vote_name','require','投票主题不能为空'),
		array('vote_name','','投票主题已经存在',0,'unique',1),
	);

	public $_auto		=	array(	
		array('vote_visible','1',1),
		array('vote_status','0',1),
		array('vote_count','0',1),
		array('vote_addtime','time',1,'function'),
		array('vote_starttime','local_strtotime',3,'callback'),
		array('vote_endtime','local_strtotime',3,'callback'),
	);

	/**
	* $time = mktime($hour, $minute, $second, $month, $day, $year) - date('Z') + (date('Z') - $timezone * 3600)
	* 先用mktime生成时间戳，再减去date('Z')转换为GMT时间，然后修正为用户自定义时间。以下是化简后结果
	**/
	protected function local_strtotime($str) {
		$timezone = C('server_timezone')? C('server_timezone') : '8';	
		$time = strtotime($str) - $timezone * 3600;
		return $time;
	}	
	
}

?>